<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
     <%@ page import="java.util.*" %>
    <%@ page import="Beans.Veiling" %>
   
    <%@ page import="Database.DBmanager" %>
    
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>


<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">




<title>Insert title here</title>
</head>
<body>
	<div id = "createddiv" class="content" >
	
`
			<%
				if(request.getAttribute("veilingen") != null){
				LinkedList<Veiling> mvs = (LinkedList<Veiling>) request.getAttribute("veilingen");
				Iterator<Veiling> i = mvs.iterator();
				int cellCount = 0;
				int maxCols = 3;

				//out.println("<table class = \"tablestyle\">");

				while (i.hasNext()) {
					Veiling v = i.next();
					if ( cellCount % maxCols == 0) out.print("<div class = \"veilingNewLineDiv\">");
					else out.println( "<div class = \"veilingDiv\">");
					//out.println("<td class=\"tablecell\" >");
					out.println("" + v.getNaam() + "<br />");
					out.println(" <img src=\"" + v.getImageURL()
							+ "\" style=\"max-width:200px;max-height:200px;\"  />");
					
					out.println("<br />");
					long timeleft = (v.getSluitDatum() - System.currentTimeMillis())/1000;
					if(timeleft >= 0){
						long dagen = (timeleft/86400);
						long uren = (timeleft%86400)/3600;
						long minuten = ((timeleft%3600)/60);
						long seconden = timeleft%60;
						String timeString =  seconden + "s";
						
						if(dagen > 0)timeString = dagen + "d " + uren + "h " + minuten + "m " +  timeString; 
						else if(uren > 0)timeString = uren + "h " + minuten + "m " +  timeString;
						else if(minuten > 0)timeString = minuten + "m " +  timeString; 
						out.println(timeString);
					}
					
					else out.println("gesloten");
					
					out.println("</div>");
					
					cellCount++;

				}
				
				}
			%>
			<div class = "clear">&nbsp;</div>
		</div>
</body>
</html>